
#include "stdafx.h"
#include <stdio.h>
#include <stdlib.h>
#include <time.h>
#include <iostream>
using namespace std;

void Swap(int elem1, int elem2)
{int c;
c=elem1;
elem1=elem2;
elem2=c;

}
 
void ShakerSort(int arr[], int beg, int n)
{
    int L, R;
    L= beg;
    R=n-1;
 
 while (L<=R)
        {
               for (int i=R; i>L; i--)
        {
            if (arr[i]<arr[i - 1])
                Swap(arr[i], arr[i-1]);
        }
 
        L= L+ 1;

        for (int i = L; i < R; i++)
        {
            if (arr[i] > arr[i + 1])
                Swap(arr[i], arr[i + 1]);
        }
 
        R= R- 1;
    } 
}

int _tmain(int argc, _TCHAR* argv[])
{
	int arr[100];
	int i;
	int n;
	srand((unsigned) time(NULL));
	printf("vvedite razmer massiva");
cin>>n;
for (i=0;i<n;i++)
{
arr[i]=rand()%100;
printf("%d ",arr[i]);
}
ShakerSort(arr,0,n);
for (i=0;i<n;i++);
printf("%d ",arr[i]);
	return 0;
}

